from ultralytics import YOLO

# Create a new YOLO model from scratch
# model = YOLO("yolov8n.yaml")

# Load a pretrained YOLO model (recommended for training)
model = YOLO("yolov8n.pt")
# model = YOLO("yolov8n-cls.pt")
# model = YOLO("yolov8n.onnx")

# Train the model using the 'coco8.yaml' dataset for 3 epochs
# results = model.train(data="coco8.yaml", epochs=3)

# Evaluate the model's performance on the validation set
# results = model.val()
"""
cd /Users/adam/PycharmProjects/detectron2/demo
conda activate pytorch-dev2
python demo.py --config-file ../configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml  --input t4.jpg --opts MODEL.WEIGHTS X101-FPN-model_final_68b088.pkl MODEL.DEVICE cpu

python demo.py --config-file ../configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml  --input t4.jpg --opts MODEL.WEIGHTS R50-C4-model_final_721ade.pkl MODEL.DEVICE cpu
"""
# Perform object detection on an image using the model
# results = model("D:\\download\\bus.jpg")
results = model.predict("/Users/adam/PycharmProjects/detectron2/demo/t4.jpg", classes=[0])

for result in results:
    result.show()

# Export the model to ONNX format
# success = model.export(format="onnx")